The N+1 problem occurs when fetching N parent records then issuing N individual queries for related data. Solve it with JOIN queries, batch loading with IN clauses, or ORM preloading.
Enable query logging in development: pgx log level debug or EXPLAIN ANALYZE suspicious queries
Use sqlc or GORM with Preload to generate/use optimized batch queries
DataLoader pattern for GraphQL: batch all IDs within a request cycle then fetch in one query
Look for database query counts in your APM (Datadog, New Relic) — sudden spikes indicate N+1
Code review: any DB call inside a loop is a red flag — prefer batch operations